<template>
  <el-dialog title="请选择线路起点收货仓" :visible.sync="innerVisible" :before-close="beforeClose" width="60%">
    <el-row>
      <el-col :span="24">
        <el-form ref="searchForm" class="el-form-col" :model="search" label-position="left"  label-width="100px">
          <el-row :gutter="15">
            <el-col :lg="8" :xl="8">
              <el-form-item prop="name" label="仓库名称">
                <el-input clearable placeholder="" v-model="search.name"></el-input>
              </el-form-item>
            </el-col>
            <el-col :lg="5" :xl="5">
              <el-form-item >
                <el-button type="primary" @click.prevent="searchFunc(search)">搜索</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="24">
        <BasicTable
          ref="BasicTable"
          url="/ms-warehouse-order/ch-warehouse-manager/getJHBWarehouseList"
          :tabs="tabs"
          :columns="columns">
          <template slot="column">
            <el-table-column fixed="right" width="100px" align="center" label="操作">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  @click="selectWarehouse(scope.row)"
                >
                  选择
                </el-button>
              </template>
            </el-table-column>
          </template>
        </BasicTable>
      </el-col>
    </el-row>
  </el-dialog>
</template>
<script>
import {copy} from '@/utils'
export default {
  components: {
  },
  props: {
  },
  data() {
    return {
      innerVisible: false,
      params: {
        pageSize: 20,
        pageNum: 1
      },
      search: {
        name: ''
      },
      columns: [
        {
          label: '仓库名称',
          data: 'name'
        },
        {
          label: '仓库地址',
          data: 'houseProvince+houseCity+houseDistrict+houseAddress',
          render: (data, full) => {
            return `${full.houseProvince} - ${full.houseCity} - ${full.houseDistrict} - ${full.houseAddress}`
          }
        },
        {
          label: '仓库覆盖范围',
          data: 'coverageArea'
        }
      ],
      tabs: []
    }
  },
  methods: {
    beforeClose(done) {
      done()
    },
    // 选中
    selectWarehouse(data) {
      this.$emit('value', data)
      this.hide()
    },
    show() {
      this.innerVisible = true
    },
    hide() {
      this.innerVisible = false
    },
    // 检索
    searchFunc(search) {
      const basicTable = this.$refs.BasicTable
      if (basicTable) {
        let params = copy(search)
        this.searchLoading = true
        basicTable.search(params).finally(_ => {
          this.searchLoading = false
        })
      }
    },
    // reset 重置搜索框
    reset(searchForm) {
      this.$refs.searchForm.resetFields()
    },
    // 刷新
    refresh() {
      this.$refs.dataTable.draw()
    }
  }
}
</script>
